<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="(item,index) in list">{{item}}<button @click="del(index)">删除</button></li>
        </ul>
        <button @click="add">生成</button>
    </div>
    <script>
        const app = new Vue({
            el:'#app',
            data:{
                list:[1,2,4]
            },
            methods:{
                del(index) {
                    this.list.splice(index,1)
                },
                add() {
                    const random = Math.floor(Math.random() * 20);
                    this.list.push(random)
                }
            }
        })
    </script>
</body>
</html>